package com.itheima;

public class Java_07 {
    public static void main(String[] args) {

        //案例练习：数组拷贝
        //调用方法
        int[] arr3 = new int[]{11,22,33,44,55,66,77,88};
        int[] temp = copy(arr3);
        print(temp);
    }
    //定义一个方法进行数组的拷贝
    public static int[] copy(int[] arr1){
        int[] arr2 = new int[arr1.length];
        //遍历这个数组
        for (int i = 0; i < arr1.length; i++) {
            arr2[i] = arr1[i];
        }
        return arr2;
    }
    //定义一个方法，来进行数组的打印
    public static void print(int[] arr2){
        System.out.print("[");
        for (int i = 0; i < arr2.length; i++) {
            System.out.print(arr2[i] == arr2[arr2.length-1] ? arr2[i] : arr2[i] + ",");
        }
        System.out.println("]");
    }
}
